# -- coding: utf-8 --
from wnboss02.action.ai import PurchaseRegistration
from wnboss02.action.case import TestCase
from wnboss02.action.common import Common
from wnboss02.util import FileParser, Asserts


class PurchaseRegistrationTest(TestCase):

    def setup(self):
        # 1.使用对应的角色账号登录；2.进入这个页面
        info = FileParser.read_json('../base.json')
        pr_info = eval(info['pr'])   # 采购登记的前置动作信息
        Common().do_login(*pr_info)

    def test_add_assets(self):
        testdata = FileParser.read_json('../testdata.json')
        add_assets_data = testdata['add_assets']
        pr = PurchaseRegistration()
        for data in add_assets_data:
            actual = pr.add_assets(data)
            Asserts.assert_equal(data['expect'], actual)

    def test_query_assets(self):
        testdata = FileParser.read_json('../testdata.json')
        query_assets_data = testdata['query_assets']
        pr = PurchaseRegistration()
        for data in query_assets_data:
            actual = pr.query_assets(data)
            Asserts.assert_equal(data['expect'], actual)

    def test_modify_assets(self):
        pass

    def teardown(self):
        Common().do_logout()

def run():
    pass

if __name__ == '__main__':
    prt = PurchaseRegistrationTest()
    prt.setup()
    prt.test_add_assets()
    prt.teardown()
    prt.setup()
    prt.test_query_assets()
    prt.teardown()